<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {{ $.Scratch.Set "Title" (default .Title (index .Site.Params.text (print "title_" (lower .Title)))) }}
    <title>{{ if eq ($.Scratch.Get "Title") .Site.Title }}{{ .Site.Title }}{{ else }}{{ ($.Scratch.Get "Title") }} | {{ .Site.Title }}{{ end }}</title>
    <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" />
    <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" />
    {{ partial "head_custom.html" . }}
  </head>

  <body{{if .IsPage}} class="page"{{ end }}>
    <nav class="header">
      {{ partial "banner.html" . }}
      <div class="head-meta">
      {{ if .IsPage }}
        <span><a href="{{ relURL .Site.BaseURL }}">{{ (default "Back to Home" .Site.Params.text.back) | safeHTML }}</a></span>
        {{ if .Params.date }}<span class="date">{{ .Date.Format "2006-01-02" }}</span>{{ end }}
        {{ if .File.Path }}
        {{ $RmdFile := (print .File.BaseFileName ".Rmd") }}
        {{ if (where (readDir (print "content/" .File.Dir)) "Name" $RmdFile) }}
          {{ $.Scratch.Set "FilePath" (print .File.Dir $RmdFile) }}
        {{ else }}
          {{ $.Scratch.Set "FilePath" .File.Path }}
        {{ end }}
        {{ with .Site.Params.github_edit}}
        <span><a href="{{ . }}{{ $.Scratch.Get "FilePath" }}">{{ (default "Edit this page" $.Site.Params.text.edit) | safeHTML }}</a></span>
        {{ end }}
        {{ end }}
      {{ else }}
        <span>{{ $.Scratch.Get "Title" }}</span>
        <span>{{ now.Format "2006-01-02" }}</span>
      {{ end }}
      </div>
    </nav>
